home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 11 / develop 11 code / Async Sound Helper / Sound Helper Demo / Utils.c < prev    next >
Encoding:
Text File  |  1992-07-15  |  2.9 KB  |  109 lines  |  [TEXT/MPS ]

  1. //=======================================================================================
  2. //
  3. // Utils.c - Various utility routines for SHDemo
  4. //
  5. // Written by Bryan K. Ressler (Beaker), 2/4/92
  6. //
  7. // Version 1.00, 2/4/92        Original version
  8. //         1.10, 4/11/92    Integrate final Sound Helper, clean up
  9. //
  10. //=======================================================================================
  11.  
  12. //=======================================================================================
  13. // Includes
  14. //=======================================================================================
  15. #include "Std.h"
  16. #include "SHDemo.h"
  17.  
  18. //=======================================================================================
  19. void UseCursor(short cursID)
  20. {
  21.     CursHandle    curs = nil;
  22.     
  23.     if (cursID != 0)
  24.         curs = GetCursor(cursID);
  25.  
  26.     if (curs)
  27.         SetCursor(*curs);
  28.     else SetCursor(&qd.arrow);
  29. }
  30.  
  31. //=======================================================================================
  32. void InvalItem(DialogPtr theDialog,short itemNum)
  33. {
  34.     short    aType;
  35.     Rect    aBox;
  36.     Handle    theItem;
  37.  
  38.     GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
  39.     InvalRect(&aBox);
  40. }
  41.  
  42. //=======================================================================================
  43. void SetValue(DialogPtr theDialog,short itemNum,short value)
  44. {
  45.     short    aType;
  46.     Rect    aBox;
  47.     Handle    theItem;
  48.  
  49.     GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
  50.     SetCtlValue((ControlHandle)theItem,value);
  51. }
  52.  
  53. //=======================================================================================
  54. void ErrorAlert(short strNum)
  55. {
  56.     Str255    parm;
  57.     char    blank = 0;
  58.     
  59.     GetIndString(parm, kErrStrs, strNum);
  60.     ParamText(parm, &blank, &blank, &blank);
  61.     StopAlert(kErrAlert, nil);
  62. }
  63.  
  64. //=======================================================================================
  65. void ErrorExtra(short strNum, short err)
  66. {
  67.     Str255    parm0, parm1;
  68.     char    blank = 0;
  69.     
  70.     GetIndString(parm0, kErrStrs, strNum);
  71.     NumToString((long)err, parm1);
  72.     ParamText(parm0, parm1, &blank, &blank);
  73.     StopAlert(kErrExtraAlert, nil);
  74. }
  75.  
  76. //=======================================================================================
  77. void UserItem(DialogPtr theDialog,short itemNum,
  78.     pascal void (*theProc)(WindowPtr theWindow,short itemNum))
  79. {
  80.     short    theType;
  81.     Rect    theBox;
  82.     Handle    theItem;
  83.  
  84.     GetDItem(theDialog, itemNum, &theType, &theItem, &theBox);
  85.     SetDItem(theDialog, itemNum, theType, (Handle)theProc, &theBox);
  86. }
  87.  
  88. //=======================================================================================
  89. void EnCtrl(DialogPtr theDialog,short itemNum)
  90. {
  91.     short    aType;
  92.     Rect    aBox;
  93.     Handle    theItem;
  94.  
  95.     GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
  96.     HiliteControl((ControlHandle)theItem,0);
  97. }
  98.  
  99. //=======================================================================================
  100. void DisCtrl(DialogPtr theDialog,short itemNum)
  101. {
  102.     short    aType;
  103.     Rect    aBox;
  104.     Handle    theItem;
  105.  
  106.     GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
  107.     HiliteControl((ControlHandle)theItem,255);
  108. }
  109.